﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace S.Y.Passport.Infacet
{
    public class BaseRepo<T> : IBaseRepo<T> where T : class
    {
        private readonly SyDbContext db;

        public BaseRepo(SyDbContext db) 
        {
            this.db = db;
        }
        public int Add(T entity)
        {
            db.Set<T>().Add(entity);

            return db.SaveChanges();
        }

        public IQueryable<T> GetAll()
        {
            return db.Set<T>().AsQueryable();
        }

        public int Update(T entity)
        {
            db.Set<T>().Update(entity);

            return db.SaveChanges();
        }
    }
}
